using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;

namespace IllSoft.Xvcc.Volano.Client
{
    public enum EventDetails
    {
        Myself,
        Sent,
        Someone
    }

    public enum JoinError
    {
        /// <summary>
        /// Channel was successfully joined.
        /// </summary>
        Success,
        /// <summary>
        /// Channel was already joined.
        /// </summary>
        ChannelAlreadyJoined,
        /// <summary>
        /// Channel is full.
        /// </summary>
        ChannelFull,
        /// <summary>
        /// Nick is either registered or contains invalid characters.
        /// </summary>
        NickRegistered,
        /// <summary>
        /// Nick is already in use by another user.
        /// </summary>
        NickInUse
    }

    public enum MessageType
    {
        Channel,
        Info,
        Query
    }

    /// <summary>
    /// Represents event args for an audio alarm
    /// </summary>
    public class AudioAlarmEventArgs : EventArgs
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="otherNick"></param>
        public AudioAlarmEventArgs(Channel channel, User otherUser, EventDetails eventDetails)
        {
            this.Channel = channel;
            this.OtherUser = otherUser;
            this.EventDetails = eventDetails;
        }

        public Channel Channel { get; private set; }
        public EventDetails EventDetails { get; private set; }
        public User OtherUser { get; private set; }
    }

    public class ChannelEventArgs : EventArgs
    {
        public ChannelEventArgs(Channel channel, User user, EventDetails eventDetails, JoinError joinError)
        {
            this.Channel = channel;
            this.User = user;
            this.EventDetails = eventDetails;
            this.JoinError = joinError;
        }

        public Channel Channel { get; private set; }
        public EventDetails EventDetails { get; private set; }
        public JoinError JoinError { get; private set; }
        public User User { get; private set; }
    }

    public class ChannelListEventArgs : EventArgs
    {
        public ChannelListEventArgs(StringCollection channels)
        {
            this.Channels = channels;
        }

        public StringCollection Channels { get; private set; }
    }

    /// <summary>
    /// Represents event args for a message.
    /// </summary>
    public class MessageEventArgs : EventArgs
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="channelName"></param>
        /// <param name="nick"></param>
        /// <param name="message"></param>
        /// <param name="messageType"></param>
        public MessageEventArgs(User user, string message, EventDetails eventDetails)
        {
            this.EventDetails = eventDetails;
            this.Message = message;
            this.User = user;
        }

        public EventDetails EventDetails { get; private set; }
        public string Message { get; private set; }
        public User User { get; private set; }
    }

    /// <summary>
    /// Represents event args for a parting a channel/query
    /// </summary>
    public class PartEventArgs : EventArgs
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="user">The user who parted the channel/query.</param>
        /// <param name="eventDetails">Specifies who parted the channel/query.</param>
        public PartEventArgs(User user, EventDetails eventDetails)
        {
            this.User = user;
            this.EventDetails = eventDetails;
        }

        public EventDetails EventDetails { get; private set; }
        public User User { get; private set; }
    }

    /// <summary>
    /// Represents event args for query related events.
    /// </summary>
    public class QueryEventArgs : EventArgs
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="myself">Myself</param>
        /// <param name="otherUser">Other user</param>
        public QueryEventArgs(User myself, User otherUser)
        {
            this.Myself = myself;
            this.OtherUser = otherUser;
        }

        public User Myself { get; private set; }
        public User OtherUser { get; private set; }
    }

    public class UserListEventArgs : EventArgs
    {
        public UserListEventArgs(Channel channel)
        {
            this.Channel = channel;
        }

        public Channel Channel { get; private set; }
    }
}